home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / f_flipv.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  2.1 KB  |  78 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include <string.h>
  19.  
  20. #include "filter.h"
  21.  
  22. static int flipv_run(const FilterActivation *fa, const FilterFunctions *ff) {
  23.     Pixel *src = (Pixel *)fa->src.data;
  24.     Pixel *dst = (Pixel *)((char *)fa->dst.data + fa->dst.pitch*(fa->dst.h-1));
  25.     unsigned long h;
  26.     unsigned long pitch = fa->src.pitch;
  27.  
  28.     h = fa->dst.h;
  29.     do {
  30.         memcpy(dst, src, fa->src.w * 4);
  31.         src = (Pixel *)((char *)src + fa->src.pitch);
  32.         dst = (Pixel *)((char *)dst - fa->dst.pitch);
  33.     } while(--h);
  34.  
  35.     return 0;
  36. }
  37.  
  38. FilterDefinition filterDef_flipv={
  39.     0,0,NULL,
  40.     "flip vertically",
  41.     "Vertically flips an image.\n\n",
  42.     NULL,NULL,
  43.     0,
  44.     NULL,NULL,
  45.     flipv_run
  46. };
  47.  
  48. ////////////////////////////////////////////////////////////
  49.  
  50. static int fliph_run(const FilterActivation *fa, const FilterFunctions *ff) {
  51.     Pixel *src = fa->src.data, *srct;
  52.     Pixel *dst = fa->dst.data-1;
  53.     unsigned long h, w;
  54.     unsigned long pitch = fa->src.pitch;
  55.  
  56.     h = fa->dst.h;
  57.     do {
  58.         srct = src;
  59.         w = fa->dst.w;
  60.         do {
  61.             dst[w] = *srct++;
  62.         } while(--w);
  63.         src = (Pixel *)((char *)src + fa->src.pitch);
  64.         dst = (Pixel *)((char *)dst + fa->dst.pitch);
  65.     } while(--h);
  66.  
  67.     return 0;
  68. }
  69.  
  70. FilterDefinition filterDef_fliph={
  71.     0,0,NULL,
  72.     "flip horizontally",
  73.     "Horizontally flips an image.\n\n",
  74.     NULL,NULL,
  75.     0,
  76.     NULL,NULL,
  77.     fliph_run
  78. };